{extends 'admin/layout/table-main.tpl'}

{block title}产品管理{/block}
{block smallTitle}系统内的产品管理。{/block}
{block head}
	<script type="text/javascript" charset="utf-8" src="{asset('admin/ueditor/ueditor.config.js')}"></script>
	<script type="text/javascript" charset="utf-8" src="{asset('admin/ueditor/ueditor.all.min.js')}"> </script>
	<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
	<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
	<script type="text/javascript" charset="utf-8" src="{asset('admin/ueditor/lang/zh-cn/zh-cn.js')}"></script>
{/block}
{block main}
	<div class="row" xmlns="http://www.w3.org/1999/html">
		<div class="col-sm-12">
			<div class="ibox float-e-margins">
				<div class="ibox-title">
					<h5>产品管理 <small>后台产品编辑</small></h5>
				</div>
				<div class="ibox-content">
					<form method="post" class="form-horizontal" action="{route('AdminOrderImportExcelFile')}">
						<div class="form-group">
							<label class="col-sm-2 col-sm-2 control-label">类型</label>

							<div class="col-sm-10">
								<select class="small m-wrap" tabindex="1" name="type" id="recommended_place">
									<option value="1" >发货</option>
									<option value="2" >签收</option>
									<option value="3" >拒签</option>
								</select>
							</div>
						</div>
						<div class="hr-line-dashed"></div>
						<div class="form-group" id="container">
							<label class="col-sm-2 col-sm-2 control-label">文件</label>

							<div class="col-sm-10">
								<input type="file" name="file" id="demo1" />
								<span class="help-inline">*</span>
							</div>
						</div>
						<div class="hr-line-dashed"></div>
						<div id="pictures_div">

						</div>
						<div class="hr-line-dashed"></div>
						<div class="form-group">
							<div class="col-sm-4 col-sm-offset-2">
								<input type="hidden" class="form-control" name="id" value="{$data.id}">
								<button class="btn btn-primary" type="submit">保存内容</button>
								<a class="btn btn-white" type="button" href="javascript:history.go(-1)">返回</a>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
{/block}
{block script}
	<script type="text/javascript" src="{asset('admin/js/ajaxfileupload/jquery-1.6.1.min.js')}"></script>
	<script type="text/javascript" src="{asset('admin/js/ajaxfileupload/jquery.ajaxfileupload.js')}"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			var interval;

			function applyAjaxFileUpload(element) {
				$(element).AjaxFileUpload({
					action: "{route('PluploadFilePull')}",
					onChange: function(filename) {
						// Create a span element to notify the user of an upload in progress
						var $span = $("<span />")
								.attr("class", $(this).attr("id"))
								.text("Uploading")
								.insertAfter($(this));

						$(this).remove();

						interval = window.setInterval(function() {
							var text = $span.text();
							if (text.length < 13) {
								$span.text(text + ".");
							} else {
								$span.text("Uploading");
							}
						}, 200);
					},
					onSubmit: function(filename) {

						// Return key-value pair to be sent along with the file
						return true;
					},
					onComplete: function(filename, response) {
						window.clearInterval(interval);
						var $span = $("span." + $(this).attr("id")).text(filename + " "),
								$fileInput = $("<input />")
										.attr({
											type: "file",
											name: $(this).attr("name"),
											id: $(this).attr("id")
										});

						if (typeof(response.error) === "string") {
							$span.replaceWith($fileInput);

							applyAjaxFileUpload($fileInput);

							alert(response.error);

							return;
						}
						$("<input>").attr("type","hidden").attr("name","file_hash").val(response.hash).appendTo($span);
						$("<a />")
								.attr("href", "javascript:;")
								.text("x")
								.bind("click", function(e) {
									$span.replaceWith($fileInput);

									applyAjaxFileUpload($fileInput);
								})
								.appendTo($span);
					}
				});
			}

			applyAjaxFileUpload("#demo1");
		});

	</script>
{/block}
